package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import dao.TeacherSql;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.AdminSql;

/**
 * Servlet implementation class AlterStudentServlet
 */
public class AlterScoreServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public AlterScoreServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.setCharacterEncoding("utf-8");
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        String ID = request.getParameter("ID");
        String Score = request.getParameter("Score");
        String Grade = request.getParameter("Grade");
        boolean a = TeacherSql.updateScore(ID, Score, Grade);
        if (a){
            response.setHeader("refresh", "1;URL=Manage_Grades.jsp");
        }else {
            out.println("录入评分失败");
            response.setHeader("refresh", "1;URL=Manage_Grades.jsp");
        }
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }
}
